package org.zjvis.graph.analysis.service.http;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.zjvis.graph.analysis.service.exception.BaseErrorCode;
import org.zjvis.graph.analysis.service.exception.GraphAnalysisException;

@Service
public class ProjectService {
    @Autowired
    private RestTemplateUtil restTemplateUtil;

    public void checkRoleAuth(Long projectId, Integer authRoleId) {
        JSONObject body = new JSONObject();
        body.put("projectId", projectId);
        body.put("authRoleId", authRoleId);
        JSONObject resp = restTemplateUtil.post("/projectsApi/checkRoleAuth", body);
        if (!resp.getBoolean("result")) {
            throw GraphAnalysisException.of(BaseErrorCode.PROJECT_NO_AUTH, "项目id:" + projectId);
        }
    }
}
